<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" class="formWidth" label-width="120px">
      <el-form-item label="与烈士关系" prop="relation">
        <el-select v-model="queryParams.relation" placeholder="请选择与烈士关系" clearable size="small">
          <el-option
            v-for="dict in relationOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否是持证人" prop="isHolder">
        <el-select v-model="queryParams.isHolder" placeholder="请选择是否是持证人" clearable size="small">
          <el-option
            v-for="dict in isHolderOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="烈士证明书编号" prop="martyrCertificateCode">
        <el-input
          v-model="queryParams.martyrCertificateCode"
          placeholder="请输入烈士证明书编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="孤老情况" prop="isLonely">
        <el-select v-model="queryParams.isLonely" placeholder="请选择孤老情况" clearable size="small">
          <el-option
            v-for="dict in isLonelyOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="孤儿情况" prop="isOrphan">
        <el-select v-model="queryParams.isOrphan" placeholder="请选择孤儿情况" clearable size="small">
          <el-option
            v-for="dict in isOrphanOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="供养情况" prop="supportSituation">
        <el-select v-model="queryParams.supportSituation" placeholder="请选择供养情况" clearable size="small">
          <el-option
            v-for="dict in supportSituationOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="供养单位" prop="supportUnit">
        <el-select v-model="queryParams.supportUnit" placeholder="请选择供养单位" clearable size="small">
          <el-option
            v-for="dict in supportUnitOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="careSituation">
        <el-select v-model="queryParams.careSituation" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in careSituationOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="享受待遇的证件" prop="treatmentCertificate">
        <el-input
          v-model="queryParams.treatmentCertificate"
          placeholder="请输入享受待遇的证件"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="现就业状况" prop="employmentSituation">
        <el-select v-model="queryParams.employmentSituation" placeholder="请选择现就业状况" clearable size="small">
          <el-option
            v-for="dict in employmentSituationOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="烈士姓名" prop="martyrName">
        <el-input
          v-model="queryParams.martyrName"
          placeholder="请输入烈士姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="烈士性别" prop="martyrSex">
        <el-select v-model="queryParams.martyrSex" placeholder="请选择烈士性别" clearable size="small">
          <el-option
            v-for="dict in martyrSexOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="烈士出生日期" prop="martyrBirthDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.martyrBirthDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择烈士出生日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="烈士入伍时间" prop="martyrEnlistedDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.martyrEnlistedDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择烈士入伍时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="烈士生前单位" prop="martyrUnit">
        <el-input
          v-model="queryParams.martyrUnit"
          placeholder="请输入烈士生前单位"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="牺牲日期" prop="martyrDeathDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.martyrDeathDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择牺牲日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="评定烈士时间" prop="evaluationDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.evaluationDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择评定烈士时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="评定单位" prop="evaluationUnit">
        <el-input
          v-model="queryParams.evaluationUnit"
          placeholder="请输入评定单位"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="烈士安葬地" prop="burialPlace">
        <el-select v-model="queryParams.burialPlace" placeholder="请选择烈士安葬地" clearable size="small">
          <el-option
            v-for="dict in burialPlaceOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="安葬详细地址" prop="detailBurialPlace">
        <el-input
          v-model="queryParams.detailBurialPlace"
          placeholder="请输入安葬详细地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['archive_info:family_of_martyr:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['archive_info:family_of_martyr:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['archive_info:family_of_martyr:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['archive_info:family_of_martyr:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="family_of_martyrList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="安葬详细地址" align="center" prop="id" :show-overflow-tooltip="true"/>
      <el-table-column label="与烈士关系" align="center" prop="relation" :formatter="relationFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="是否是持证人" align="center" prop="isHolder" :formatter="isHolderFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="烈士证明书编号" align="center" prop="martyrCertificateCode" :show-overflow-tooltip="true"/>
      <el-table-column label="孤老情况" align="center" prop="isLonely" :formatter="isLonelyFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="孤儿情况" align="center" prop="isOrphan" :formatter="isOrphanFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="供养情况" align="center" prop="supportSituation" :formatter="supportSituationFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="供养单位" align="center" prop="supportUnit" :formatter="supportUnitFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="" align="center" prop="careSituation" :formatter="careSituationFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="享受待遇的证件" align="center" prop="treatmentCertificate" :show-overflow-tooltip="true"/>
      <el-table-column label="现就业状况" align="center" prop="employmentSituation" :formatter="employmentSituationFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="烈士姓名" align="center" prop="martyrName" :show-overflow-tooltip="true"/>
      <el-table-column label="烈士性别" align="center" prop="martyrSex" :formatter="martyrSexFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="烈士出生日期" align="center" prop="martyrBirthDate" width="180" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.martyrBirthDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="烈士入伍时间" align="center" prop="martyrEnlistedDate" width="180" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.martyrEnlistedDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="烈士生前单位" align="center" prop="martyrUnit" :show-overflow-tooltip="true"/>
      <el-table-column label="牺牲日期" align="center" prop="martyrDeathDate" width="180" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.martyrDeathDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="评定烈士时间" align="center" prop="evaluationDate" width="180" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.evaluationDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="评定单位" align="center" prop="evaluationUnit" :show-overflow-tooltip="true"/>
      <el-table-column label="烈士安葬地" align="center" prop="burialPlace" :formatter="burialPlaceFormat" :show-overflow-tooltip="true"/>
      <el-table-column label="安葬详细地址" align="center" prop="detailBurialPlace" :show-overflow-tooltip="true"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['archive_info:family_of_martyr:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['archive_info:family_of_martyr:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改烈士遗属信息采集对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" class="formWidth" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="与烈士关系" prop="relation">
              <el-select v-model="form.relation" placeholder="请选择与烈士关系">
                <el-option
                  v-for="dict in relationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否是持证人" prop="isHolder">
              <el-select v-model="form.isHolder" placeholder="请选择是否是持证人">
                <el-option
                  v-for="dict in isHolderOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="烈士证明书编号" prop="martyrCertificateCode">
              <el-input v-model="form.martyrCertificateCode" placeholder="请输入烈士证明书编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="孤老情况" prop="isLonely">
              <el-select v-model="form.isLonely" placeholder="请选择孤老情况">
                <el-option
                  v-for="dict in isLonelyOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="孤儿情况" prop="isOrphan">
              <el-select v-model="form.isOrphan" placeholder="请选择孤儿情况">
                <el-option
                  v-for="dict in isOrphanOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供养情况" prop="supportSituation">
              <el-select v-model="form.supportSituation" placeholder="请选择供养情况">
                <el-option
                  v-for="dict in supportSituationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="供养单位" prop="supportUnit">
              <el-select v-model="form.supportUnit" placeholder="请选择供养单位">
                <el-option
                  v-for="dict in supportUnitOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供养类型" prop="careSituation">
              <el-select v-model="form.careSituation" placeholder="请选择">
                <el-option
                  v-for="dict in careSituationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="享受待遇的证件" prop="treatmentCertificate">
              <el-input v-model="form.treatmentCertificate" placeholder="请输入享受待遇的证件" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="现就业状况" prop="employmentSituation">
              <el-select v-model="form.employmentSituation" placeholder="请选择现就业状况">
                <el-option
                  v-for="dict in employmentSituationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="烈士姓名" prop="martyrName">
              <el-input v-model="form.martyrName" placeholder="请输入烈士姓名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="烈士性别" prop="martyrSex">
              <el-select v-model="form.martyrSex" placeholder="请选择烈士性别">
                <el-option
                  v-for="dict in martyrSexOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
         </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">    
            <el-form-item label="烈士出生日期" prop="martyrBirthDate">
              <el-date-picker clearable size="small"
                v-model="form.martyrBirthDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择烈士出生日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="烈士入伍时间" prop="martyrEnlistedDate">
              <el-date-picker clearable size="small"
                v-model="form.martyrEnlistedDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择烈士入伍时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"> 
            <el-form-item label="烈士生前单位" prop="martyrUnit">
              <el-input v-model="form.martyrUnit" placeholder="请输入烈士生前单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="牺牲日期" prop="martyrDeathDate">
              <el-date-picker clearable size="small"
                v-model="form.martyrDeathDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择牺牲日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"> 
            <el-form-item label="评定烈士时间" prop="evaluationDate">
              <el-date-picker clearable size="small"
                v-model="form.evaluationDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择评定烈士时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="评定单位" prop="evaluationUnit">
              <el-input v-model="form.evaluationUnit" placeholder="请输入评定单位" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"> 
            <el-form-item label="烈士安葬地" prop="burialPlace">
              <el-select v-model="form.burialPlace" placeholder="请选择烈士安葬地">
                <el-option
                  v-for="dict in burialPlaceOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="安葬详细地址" prop="detailBurialPlace">
              <el-input v-model="form.detailBurialPlace" placeholder="请输入安葬详细地址" />
            </el-form-item>
         </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listFamily_of_martyr, getFamily_of_martyr, delFamily_of_martyr, addFamily_of_martyr, updateFamily_of_martyr, exportFamily_of_martyr } from "@/api/archive_info/family_of_martyr";

export default {
  name: "Family_of_martyr",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 烈士遗属信息采集表格数据
      family_of_martyrList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 与烈士关系字典
      relationOptions: [],
      // 是否是持证人字典
      isHolderOptions: [],
      // 孤老情况字典
      isLonelyOptions: [],
      // 孤儿情况字典
      isOrphanOptions: [],
      // 供养情况字典
      supportSituationOptions: [],
      // 供养单位字典
      supportUnitOptions: [],
      // 字典
      careSituationOptions: [],
      // 现就业状况字典
      employmentSituationOptions: [],
      // 烈士性别字典
      martyrSexOptions: [],
      // 烈士安葬地字典
      burialPlaceOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        relation: null,
        isHolder: null,
        martyrCertificateCode: null,
        isLonely: null,
        isOrphan: null,
        supportSituation: null,
        supportUnit: null,
        careSituation: null,
        treatmentCertificate: null,
        employmentSituation: null,
        martyrName: null,
        martyrSex: null,
        martyrBirthDate: null,
        martyrEnlistedDate: null,
        martyrUnit: null,
        martyrDeathDate: null,
        evaluationDate: null,
        evaluationUnit: null,
        burialPlace: null,
        detailBurialPlace: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        relation: [
          { required: true, message: "与烈士关系不能为空", trigger: "change" }
        ],
        isHolder: [
          { required: true, message: "是否是持证人不能为空", trigger: "change" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("relation").then(response => {
      this.relationOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isHolderOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isLonelyOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isOrphanOptions = response.data;
    });
    this.getDicts("support_situation").then(response => {
      this.supportSituationOptions = response.data;
    });
    this.getDicts("support_unit").then(response => {
      this.supportUnitOptions = response.data;
    });
    this.getDicts("care_situation").then(response => {
      this.careSituationOptions = response.data;
    });
    this.getDicts("employment_situation").then(response => {
      this.employmentSituationOptions = response.data;
    });
    this.getDicts("s_sex").then(response => {
      this.martyrSexOptions = response.data;
    });
    this.getDicts("burial_place").then(response => {
      this.burialPlaceOptions = response.data;
    });
  },
  methods: {
    /** 查询烈士遗属信息采集列表 */
    getList() {
      this.loading = true;
      listFamily_of_martyr(this.queryParams).then(response => {
        this.family_of_martyrList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 与烈士关系字典翻译
    relationFormat(row, column) {
      return this.selectDictLabel(this.relationOptions, row.relation);
    },
    // 是否是持证人字典翻译
    isHolderFormat(row, column) {
      return this.selectDictLabel(this.isHolderOptions, row.isHolder);
    },
    // 孤老情况字典翻译
    isLonelyFormat(row, column) {
      return this.selectDictLabel(this.isLonelyOptions, row.isLonely);
    },
    // 孤儿情况字典翻译
    isOrphanFormat(row, column) {
      return this.selectDictLabel(this.isOrphanOptions, row.isOrphan);
    },
    // 供养情况字典翻译
    supportSituationFormat(row, column) {
      return this.selectDictLabel(this.supportSituationOptions, row.supportSituation);
    },
    // 供养单位字典翻译
    supportUnitFormat(row, column) {
      return this.selectDictLabel(this.supportUnitOptions, row.supportUnit);
    },
    // 字典翻译
    careSituationFormat(row, column) {
      return this.selectDictLabel(this.careSituationOptions, row.careSituation);
    },
    // 现就业状况字典翻译
    employmentSituationFormat(row, column) {
      return this.selectDictLabel(this.employmentSituationOptions, row.employmentSituation);
    },
    // 烈士性别字典翻译
    martyrSexFormat(row, column) {
      return this.selectDictLabel(this.martyrSexOptions, row.martyrSex);
    },
    // 烈士安葬地字典翻译
    burialPlaceFormat(row, column) {
      return this.selectDictLabel(this.burialPlaceOptions, row.burialPlace);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        relation: null,
        isHolder: null,
        martyrCertificate: null,
        martyrCertificateCode: null,
        isLonely: null,
        isOrphan: null,
        supportSituation: null,
        supportUnit: null,
        careSituation: null,
        treatmentCertificate: null,
        employmentSituation: null,
        martyrName: null,
        martyrSex: null,
        martyrBirthDate: null,
        martyrEnlistedDate: null,
        martyrUnit: null,
        martyrDeathDate: null,
        evaluationDate: null,
        evaluationUnit: null,
        burialPlace: null,
        detailBurialPlace: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加烈士遗属信息采集";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getFamily_of_martyr(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改烈士遗属信息采集";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateFamily_of_martyr(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addFamily_of_martyr(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除烈士遗属信息采集编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delFamily_of_martyr(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有烈士遗属信息采集数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportFamily_of_martyr(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
